package com.ssm;

import com.ssm.service.CardService;
import com.ssm.service.impl.CardServiceImpl;
import com.sun.jna.Library;
import com.sun.jna.Native;
//import org.apache.crimson.tree.XmlDocument;
import org.apache.axis.utils.StringUtils;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Text;

import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.apache.axis.utils.XMLUtils.getDocumentBuilder;

public class cardTest {
  public interface testdll extends Library {
      testdll instance = (testdll) Native.loadLibrary("C:\\Windows\\System32\\msvcrt", testdll.class);
      void printf(String format,Object... args);
//      int add(int a,int b);
  }

    public static void main(String[] args) {
        testdll.instance.printf("yyyyMMdd");
//        int add = testdll.instance.add(3, 6);
//        System.out.println("dll调用add方法的和是："+add);

    }
    @Test
    public void cTest(){
      String cityNum;
      String cardNumber;
      String CardNum;
      String  CardName;
      String str="412726199609120821";
        String testStr = "<ERR>OK</ERR><时间>20120610070940</时间><AAB301>440200</AAB301><AAZ500>F20000082</AAZ500><AAC002>111111111111111111</AAC002><ZJYXQ>20300101</ZJYXQ>\n" +
                "   <AAC003>姓名1</AAC003><AAC004>1</AAC004><AAC005>01</AAC005><AAC006>19800101</AAC006><AAC008>1</AAC008><AAC009>11</AAC009><AAC010>户口地址1</AAC010><MOBILE>手机</MOBILE>\n" +
                "   <AAE005>电话</AAE005><AAE006>通讯地址</AAE006><AAE007>123456</AAE007><EMAIL>111@111.com</EMAIL><AAB001>单位编号</AAB001><AAB004>单位名称1</AAB004><JHRZH>监护人证号</JHRZH>\n" +
                "   <JHRXM>监护人姓名</JHRXM>其中<AAC008>1</AAC008>";
//        System.out.println(testStr);
//        Pattern p = Pattern.compile(">([^</]+)</");
//        Pattern p = Pattern.compile(">(.*)</");
//        Matcher m = p.matcher(testStr);
//        System.out.println(m.group(1)+"m.group");
//        while(m.find()){
//            System.out.println(m.group(1));
//        }
        Pattern compile = Pattern.compile("<AAB301>(.*)</AAB301>");
        Pattern compile1 = Pattern.compile("<AAZ500>(.*)</AAZ500>");
        Pattern compile2= Pattern.compile("<AAC002>(.*)</AAC002>");
        Pattern compile3 = Pattern.compile("<ZJYXQ>(.*)</ZJYXQ>");
        Pattern compile4= Pattern.compile("<AAC003>(.*)</AAC003>");
        Matcher matcher = compile.matcher(testStr);
        Matcher matcher1 = compile1.matcher(testStr);
        Matcher matcher2= compile2.matcher(testStr);
        Matcher matcher3= compile3.matcher(testStr);
        Matcher matcher4= compile4.matcher(testStr);
        while (matcher.find()&&matcher1.find()&&matcher2.find()&&matcher3.find()&&matcher4.find()){
            cityNum=matcher.group(1);
            cardNumber=matcher1.group(1);
            CardNum=matcher2.group(1);
            CardName=matcher4.group(1);
            System.out.println(cityNum+"cityNum   "+cardNumber+"cardNumber   "+CardNum+"cardNum  "+CardName+"cardName  ");
        }
    }
    @Test
    public void testB(){
        CardService cardService=new CardServiceImpl();
        Integer integer = cardService.insertCard("bb", "1", "Pdhdajlj45", "412726199609120823");
        System.out.println("integer的值是："+integer);
    }



}
